package ua.net.gm.common.entity;

import ua.net.gm.common.matter.MatterId;

/**
 *
 * @author Yason
 */
public abstract class EntitySupport
{
    private final EntityIdFactory idFactory = new EntityIdFactory();
    
    private final EntityTypeFactory entityTypeFactory = new EntityTypeFactory();    
    
    private final EntityDictCatalog dictCatalog = new EntityDictCatalog();

    EntityIdFactory getEntityIdFactory()
    {
        return idFactory;
    }

    EntityTypeFactory getEntityTypeFactory()
    {
        return entityTypeFactory;
    }
    
    public EntityType createType(String type, IEntityDictFactory factory)
    {
        EntityType res = getEntityTypeFactory().createType(type);
        dictCatalog.createDict(res, factory, this);
        return res;
    }
    
    public EntityType createType(String type)
    {
        EntityType res = getEntityTypeFactory().createType(type);
        dictCatalog.createDict(res, new DefaultDictFactory(), this);
        return res;
    }

    public IEntityDict<MatterId> getMatterDict()
    {
        return getDict(MatterId.ID);
    }
    
    public IEntityDict getDict(String name)
    {
        return dictCatalog.getDict(name);
    }
    
    public void init()
    {
       MatterId.init(this); 
       
       initDictCatalog();
    }
    
    protected abstract void initDictCatalog();
}
